package com.shengyin.ec.model.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.compass.annotations.Index;
import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;
import org.compass.annotations.Store;


@Entity
@Table(name="goods")
@Searchable
public class Goods extends BaseEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name="typeId")
	private GoodsType goodsType;
	
	@ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name="companyId")
	private ClusterCompany clusterCompany;
	
	@OneToMany(cascade={CascadeType.MERGE,CascadeType.REFRESH},mappedBy="goods")
	private List<OrderItem> orderItem;
	
	@Transient
	static long productId=00000000;
	
	private String productName;
	private String productType;
	private String productCode;
	private String productCompany;
	private String productReserves;
	
	
	private int productWeight;
	private String productMeasurement;
	private int totalCount;
	private int sellCount;
	private String productPicture;
	private String PriewPic;
	private float marketPrice;
	private float ourPrice;
	private float discount;
	private String specifications;
	private String createDate;
	private String updateTime;
	
	
	
	private int  isNew;
	private int isCommond;
	private int isPromotion;
	private int isVisible;
	/*????*/
	@OneToMany(cascade={CascadeType.MERGE,CascadeType.REFRESH},mappedBy="goods")
	private List<Comment> comments = new ArrayList<Comment>();
	
	@SearchableId
	@Override
	public Long getId() {
		return super.getId();
	}
	public static long getProductId() {
		return productId;
	}
	public static void setProductId(long productId) {
		Goods.productId = productId;
	}


	@Lob
	private String description;
	
	
	public String getSpecifications() {
		return specifications;
	}
	public void setSpecifications(String specifications) {
		this.specifications = specifications;
	}
	public String getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}
	@SearchableProperty(boost=2,name="productName")
	public String getProductName() {
		return productName;
	}
	public void setProductName(String productName) {
		this.productName = productName;
	}
	@SearchableProperty(index=Index.NO,store=Store.YES)
	public String getProductType() {
		return productType;
	}
	public void setProductType(String productType) {
		this.productType = productType;
	}
	public String getProductCode() {
		return productCode;
	}
	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}
	@SearchableProperty(index=Index.NO,store=Store.YES)
	public String getProductCompany() {
		return productCompany;
	}
	public void setProductCompany(String productCompany) {
		this.productCompany = productCompany;
	}
	public String getProductReserves() {
		return productReserves;
	}
	public void setProductReserves(String productReserves) {
		this.productReserves = productReserves;
	}
	public int getProductWeight() {
		return productWeight;
	}
	public void setProductWeight(int productWeight) {
		this.productWeight = productWeight;
	}
	public String getProductMeasurement() {
		return productMeasurement;
	}
	public void setProductMeasurement(String productMeasurement) {
		this.productMeasurement = productMeasurement;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public String getPriewPic() {
		return PriewPic;
	}
	public void setPriewPic(String priewPic) {
		PriewPic = priewPic;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public int getSellCount() {
		return sellCount;
	}
	public void setSellCount(int sellCount) {
		this.sellCount = sellCount;
	}
	@SearchableProperty(index=Index.NO,store=Store.YES)
	public String getProductPicture() {
		return productPicture;
	}
	public void setProductPicture(String productPicture) {
		this.productPicture = productPicture;
	}
	public float getMarketPrice() {
		return marketPrice;
	}
	public void setMarketPrice(float marketPrice) {
		this.marketPrice = marketPrice;
	}
	public float getOurPrice() {
		return ourPrice;
	}
	public void setOurPrice(float ourPrice) {
		this.ourPrice = ourPrice;
	}
	public float getDiscount() {
		return discount;
	}
	public void setDiscount(float discount) {
		this.discount = discount;
	}
	public String getCreateDate() {
		return createDate;
	}
	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}
	public int getIsNew() {
		return isNew;
	}
	public void setIsNew(int isNew) {
		this.isNew = isNew;
	}
	public int getIsCommond() {
		return isCommond;
	}
	public void setIsCommond(int isCommond) {
		this.isCommond = isCommond;
	}
	public int getIsPromotion() {
		return isPromotion;
	}
	public void setIsPromotion(int isPromotion) {
		this.isPromotion = isPromotion;
	}
	public int getIsVisible() {
		return isVisible;
	}
	public void setIsVisible(int isVisible) {
		this.isVisible = isVisible;
	}
	@SearchableProperty
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	public static long  getProductID(){
		return ++productId;
	}
	public ClusterCompany getClusterCompany() {
		return clusterCompany;
	}
	public void setClusterCompany(ClusterCompany clusterCompany) {
		this.clusterCompany = clusterCompany;
	}
	public List<OrderItem> getOrderItem() {
		return orderItem;
	}
	public void setOrderItem(List<OrderItem> orderItem) {
		this.orderItem = orderItem;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	@JsonIgnore
	public List<Comment> getComments() {
		return comments;
	}
	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}
	public GoodsType getGoodsType() {
		return goodsType;
	}
	public void setGoodsType(GoodsType goodsType) {
		this.goodsType = goodsType;
	}
	
	
}
